package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;
import com.stark.picselect.entity.SelectMediaEntity;

import java.util.List;

import flc.ast.bean.MyAlbumBean;
import flc.ast.bean.MyImgItemBean;
import flc.ast.bean.MyPicLibraryBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void saveCollectList(List<SelectMediaEntity> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_video_collect_list, json);
    }

    public static List<SelectMediaEntity> getCollectList() {
        String json = sSpUtils.getString(Key.key_video_collect_list);
        return GsonUtils.fromJson(json, new TypeToken<List<SelectMediaEntity>>() {
        }.getType());
    }

    public static void savePicCollectList(List<String> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_pic_collect_list, json);
    }

    public static List<String> getPicCollectList() {
        String json = sSpUtils.getString(Key.key_pic_collect_list);
        return GsonUtils.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
    }

    //视频相册
    public static void saveAlbumList(List<MyAlbumBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_video_album_list, json);
    }

    public static List<MyAlbumBean> getAlbumList() {
        String json = sSpUtils.getString(Key.key_video_album_list);
        return GsonUtils.fromJson(json, new TypeToken<List<MyAlbumBean>>() {
        }.getType());
    }

    //图片相册
    public static void savePictureList(List<MyPicLibraryBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_pic_album_list, json);
    }

    public static List<MyPicLibraryBean> getPictureList() {
        String json = sSpUtils.getString(Key.key_pic_album_list);
        return GsonUtils.fromJson(json, new TypeToken<List<MyPicLibraryBean>>() {
        }.getType());
    }

    interface Key {
        String key_video_collect_list = "key_video_collect_list";
        String key_pic_collect_list = "key_pic_collect_list";
        //视频相册
        String key_video_album_list = "key_video_album_list";

        //图片相册
        String key_pic_album_list = "key_pic_album_list";
    }
}